// 防抖
function debounce(func, wait, immediate) {
	console.log('防抖');
	// 定义一个定时器
	let timeout;
	return function(...args) {
		const context = this;
		const later = function() {
			// 清空定时器
			timeout = null;
			if (!immediate) func.apply(context, args);
		};
		const callNow = immediate && !timeout;
		// 清空定时器
		clearTimeout(timeout);
		timeout = setTimeout(later, wait);
		if (callNow) func.apply(context, args);
	};
}
export {
	debounce,
}